add_subdirectory(benchmark)
add_subdirectory(ext/http_parser)

FILE(GLOB DOUBLE_SRC "common/double-conversion/*.cc")
FILE(GLOB DOUBLE_HEADER "common/double-conversion/*.h")

FILE(GLOB COMMON_SRC "common/*.cc")
FILE(GLOB COMMON_HEADER "common/*.h")

FILE(GLOB UTIL_SRC "util/*.cc")
FILE(GLOB UTIL_HEADER "util/*.h")

FILE(GLOB PARSER_SRC "parser/*.cc")
FILE(GLOB PARSER_HEADER "parser/*.h")

FILE(GLOB EVENT_SRC "event/*.cc")
FILE(GLOB EVENT_HEADER "event/*.h")

FILE(GLOB DIO_SRC "dio/*.cc")
FILE(GLOB DIO_HEADER "dio/*.h")

FILE(GLOB NET_SRC "net/*.cc")
FILE(GLOB NET_HEADER "net/*.h")

FILE(GLOB MONITOR_SRC "monitor/*.cc")
FILE(GLOB MONITOR_HEADER "monitor/*.h")

FILE(GLOB HTTP_SRC "http/*.cc")
FILE(GLOB HTTP_HEADER "http/*.h")

FILE(GLOB SERVICE_SRC "service/*.cc")
FILE(GLOB SERVICE_HEADER "service/*.h")

FILE(GLOB FLUAPP_SRC "fluapp/*.cc")
FILE(GLOB FLUAPP_HEADER "fluapp/*.h")


FILE(GLOB DNS_SRC "dns/*.cc")
FILE(GLOB DNS_HEADER "dns/*.h")

SET(ALL_SRC
	${COMMON_SRC}
    ${UTIL_SRC}
	${PARSER_SRC}
	${EVENT_SRC}
	${DIO_SRC}
	${NET_SRC}
	${HTTP_SRC}
	${DOUBLE_SRC}
    ${SERVICE_SRC}	
	)


add_library(fermatStatic STATIC ${ALL_SRC} )
add_library(fermatShared SHARED ${ALL_SRC} )
target_link_libraries(fermatStatic http_parserStatic pthread rt)
target_link_libraries(fermatShared http_parserShared pthread rt)
set_target_properties(fermatStatic PROPERTIES OUTPUT_NAME 
	fermat_static)
set_target_properties(fermatShared PROPERTIES OUTPUT_NAME 
	fermat)


install(TARGETS fermatStatic fermatShared 
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib 
	ARCHIVE DESTINATION lib
	 )

if(_DEVEL)
	install (FILES ${COMMON_HEADER}  DESTINATION include/fermat/common)
	install (FILES ${DOUBLE_HEADER}  DESTINATION include/fermat/common/double-conversion)
	install (FILES ${UTIL_HEADER}    DESTINATION include/fermat/util)
	install (FILES ${PARSER_HEADER}  DESTINATION include/fermat/parser)
	install (FILES ${EVENT_HEADER}   DESTINATION include/fermat/event)
	install (FILES ${DIO_HEADER}     DESTINATION include/fermat/dio)
	install (FILES ${NET_HEADER}     DESTINATION include/fermat/net)
	install (FILES ${MONITOR_HEADER} DESTINATION include/fermat/monitor)
	install (FILES ${HTTP_HEADER}    DESTINATION include/fermat/http)
	install (FILES ${SERVICE_HEADER} DESTINATION include/fermat/service)
	install (DIRECTORY ${PROJECT_SOURCE_DIR}/fermat/log DESTINATION include/fermat)
	install (DIRECTORY ${PROJECT_SOURCE_DIR}/fermat/config DESTINATION include/fermat)
	install (DIRECTORY ${PROJECT_SOURCE_DIR}/fermat/ext/json DESTINATION include/fermat/ext)
	install (DIRECTORY ${PROJECT_SOURCE_DIR}/fermat/ext/xml DESTINATION include/fermat/ext)
endif()